package externalflame.systemdesign.newsfeed.service.impl;

import externalflame.systemdesign.newsfeed.dao.FriendDao;
import externalflame.systemdesign.newsfeed.service.FriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class BidirectFriendService implements FriendService {

    @Autowired
    FriendDao friendDao;

    @Transactional
    @Override
    public String follow(Long userId, Long toUserId) {
        friendDao.add(userId, toUserId);
        friendDao.add(toUserId, userId);
        return "Success";
    }

    @Transactional
    @Override
    public String unfollow(Long userId, Long toUserId) {
        friendDao.remove(userId, toUserId);
        friendDao.remove(toUserId, userId);
        return "Success";
    }
}
